package cn.stylefeng.guns.modular.replenishment.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.replenishment.entity.ReplenishmentOrder;
import cn.stylefeng.guns.modular.replenishment.model.params.ReplenishmentOrderParam;
import cn.stylefeng.guns.modular.replenishment.service.ReplenishmentOrderService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import com.jushuitan.api.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 补货单控制器
 *
 * @author wp
 * @Date 2025-05-26 11:11:51
 */
@Controller
@RequestMapping("/replenishmentOrder")
public class ReplenishmentOrderController extends BaseController {

    private String PREFIX = "/replenishment/replenishmentOrder";

    @Autowired
    private ReplenishmentOrderService replenishmentOrderService;

    @Autowired
    private UserService userService;

    /**
     * 跳转到主页面
     *
     * @author wp
     * @Date 2025-05-26
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/replenishmentOrder.html";
    }

    /**
     * 新增页面
     *
     * @author wp
     * @Date 2025-05-26
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/replenishmentOrder_add.html";
    }

    /**
     * 编辑页面
     *
     * @author wp
     * @Date 2025-05-26
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/replenishmentOrder_edit.html";
    }

    /**
     * 新增接口
     *
     * @author wp
     * @Date 2025-05-26
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ReplenishmentOrderParam replenishmentOrderParam) {
        this.replenishmentOrderService.add(replenishmentOrderParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author wp
     * @Date 2025-05-26
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ReplenishmentOrderParam replenishmentOrderParam) {
        this.replenishmentOrderService.update(replenishmentOrderParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author wp
     * @Date 2025-05-26
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ReplenishmentOrderParam replenishmentOrderParam) {
        this.replenishmentOrderService.delete(replenishmentOrderParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author wp
     * @Date 2025-05-26
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ReplenishmentOrderParam replenishmentOrderParam) {
        ReplenishmentOrder detail = this.replenishmentOrderService.getById(replenishmentOrderParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author wp
     * @Date 2025-05-26
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ReplenishmentOrderParam replenishmentOrderParam,String condition ) {
        return this.replenishmentOrderService.findPageBySpec(replenishmentOrderParam,condition);
    }

    /**
     * 生成补货单
     * @return
     */
    @ResponseBody
    @RequestMapping("/generateReplenishmentOrder")
    public ResponseData generateReplenishmentOrder(String goodsNumber,String goodsCount ) {
        return this.replenishmentOrderService.generateReplenishmentOrder(goodsNumber,goodsCount);
    }

}


